home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq21.zip
/
JOINCONF.SLT
< prev
next >
Wrap
Text File
|
1992-03-20
|
11KB
|
325 lines
//-----------------------------------------------------------
// JOINCONF.SLT Join Conference.
// If you have suggestions for improving this script, please suggest
// improvements to me via old-fashioned snail-mail to:
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
// tel. (472) 546 396
str bbs_type [32] // BBS type.
,PrevConf [20]="" // Previous conference.
,NextConf [20]="" // Next conference.
,command [10] // Command prompt.
,temp [4] // Temporary for short strings.
// For the Global storage:
,global []="GLOBAL" // Global script.
,bbstype []="BTYPE" // BBS type.
,conf []="CONF" // Current conference
,prompt []="PROMPT" // Current command prompt.
,ronly []="RONLY" // Read Only conference.
;
int tol = 100 // No activity for 10 sec.
,stat, tmark // makes script time out.
,mbbs, pcb, rbbs, opus, fido, crcs
,Enter=13
;
//-----------------------------------------------------------
// Script starts here.
//-----------------------------------------------------------
main (str NewConf)
{
int c, i, j, ercnt, switched
,yes, ent, par, con, com, bad, ro, co, y;
str Sline [80]
,pre [4]
,post [4]
,end [4]
,ans [14]
;
NextConf = NewConf; // Use local, since it may
// be changed.
// Only if online.
if (!carrier())
{ failtone();
status_wind ("T²: YOU CAN'T JOIN A CONFERENCE IF YOU'RE OFFLINE!",20);
return (-1);
}
read (bbstype,bbs_type); // Get BBS type.
read (conf,PrevConf); // Get previous conference.
read (prompt,command); // Get command prompt.
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (bbs_type == "MBBS") mbbs = 1;
else if (bbs_type == "PCB") pcb = 1;
else if (bbs_type == "RBBS") rbbs = 1;
else if (bbs_type == "OPUS") opus = 1;
else if (bbs_type == "FIDO") fido = 1;
else if (bbs_type == "CRCS") crcs = 1;
else
{ wrongBBS(bbs_type); // Don't know how to do it!
return (-1);
}
if (mbbs)
{ pre = "("; // Define the delimiters
post = ")"; // for the conference
end = "Q^M"; // name.
}
else if (pcb)
{ pre = "t) ";
post = " (";
end = "^M";
}
else if (rbbs)
{ pre = "";
post = " Co";
end = "^M";
}
co = strlen(pre); // Length of prefix.
flush();
y=gety();
if (rbbs)
{ --y; // RBBS:
if (y<0) y=0; // Conf. name on previous line.
}
vgetchrs(0,y,Sline,0,80); // Get command line from screen.
if (pcb) // PCBoard: Do some extra checks
{ if (strposi(PrevConf,"Main",0)== 0 // for Main Board.
|| strposi(Sline,"Main Boa",0) > 0)
{ PrevConf = "Main Board"; // Set Main Board.
write (conf,PrevConf);
}
}
if (strlen(PrevConf) < 1) do // Have to find which conference
{ j = -1;
vgetchrs(0,gety(),Sline,0,80); // Get command line from screen.
if (rbbs) // RBBS: Conference name
i = 0; // at beginning of line.
else
{ i = strposi(Sline,pre,0); // Find start byte.
if (i < 0)
{ i = strposi(Sline,"[",0); // Not found: Try "[".
if (i >= 0) // Is this the old format?
{ co = 1; // Yepp.
pre = "["; // Starts with a left bracket,
post = "]"; // ends with a right bracket.
}
}
i = i+co; // Proceed to conference name.
}
j = strposi (Sline,post,i); // Find end byte.
j = j-i; // Find the length.
if (j>0)
substr (Sline,i,j,PrevConf); // Conference found!
else
cputs (end); // Not found: Back to Main.
flush();
} while (j < 1);
// Previous conference known.
for (i=0; subchr(NextConf,i)<=' ';++i) // Find first non-space.
; // Find end of line.
j = -1;
for (; (c=subchr(NextConf,i)) > ' ' ;++i)
setchr(NextConf,++j,c); // Get up to first space.
setchr(NextConf,++j,0);
ercnt = switched = 0;
if (pcb)
{ if (strposi(NextConf,"Main",0) >= 0)
NextConf = "Main Board"; // Only one legal name
if (strposi(PrevConf,"Main",0) >= 0) // for Main Board.
PrevConf = "Main Board";
}
if (strposi(PrevConf,NextConf,0)==0) // Same conference?
{ if (!mbbs) return (0); // Ignore unless it's MBBS.
if (strposi (Sline," Read ",0) >= 0) return 0; // Read; OK.
cputs ("^M"); // No, get Read Command
waitfor (command,1); // and wait.
return 0;
}
while (!switched && ercnt < 4) // Until conference changed:
{ if (pcb && strposi(NextConf,"Main Board",0)==0)
cputs("A"); // Abandon Main Board.
else
{ cputs("J "); // join the conference.
cputs(NextConf);
}
write (ronly,"NO"); // NOT read only.
ans = ""; // Next answer.
con = track (NextConf,1); // Check conference name.
if (pcb)
{ ent = track("(Enter)=",0);
par = track("left)",0); // ...minutes left
com = track(command,0);
bad = 0;
}
else
{ par = -948; // Not used for MBBS.
if (mbbs)
{ com = track(command,0);
ent = track("nter=none>:",0); // Wrong selection.
bad = track("lid command",0); // Invalid command.
ro = track("READ ONLY",0); // Read Only conference.
}
else if (rbbs)
{ com = track("V,W,X>?",0);
ans = "n^M"; // Browse conference without
ent = track("Y,[N])?",0); // permanently joining (Y,[N])?
switched = 1;
}
}
flush();
cputs("^M");
tmark = timer_start (tol); // Just 10 sec. time-out.
while ((stat=trig()) > 0 && ++ercnt < 4) // Wait for Command.
{ if (stat == ent)
{ ++ercnt;
if (pcb) // PCBoard:
{ terminal();
y=gety();
vgetchrs(0,y,Sline,0,80); // Get command line from screen.
if (strpos (Sline,"Mail Com") >=0)
ans = "qu"; // .... Main Board (0) Mail Command: (Enter)='xx...
else
ans = "n"; // Scan since last read?
} // Scan for personal mail?
else if (mbbs)
ans = NextConf; // Wrong conference. Try again.
cputs (ans); // Send answer.
cputs ("^M");
}
else if (stat == par) // (Quit from mail command)
break; // ...minutes left)
else if (stat == bad) // Invalid command:
{ prints ("???? ERROR ????");
break; // Try again.
}
else if (stat == com) // Command:
{ if (switched) // Check switch. If non-zero
write (conf,NextConf); // we're in this conference.
break;
}
else if (stat == ro) // Read Only conference?
write (ronly,"YES"); // Mark it.
else if (stat == con) // Conference name?
{ --ercnt;
switched = 1; // We've switched.
}
}
track_free(0);